package com.zz.framework.core.widget

import android.content.Context
import android.content.DialogInterface
import android.graphics.Color
import androidx.appcompat.app.AlertDialog

class XAlertDialog : AlertDialog {
    protected constructor(context: Context) : super(context) {}
    protected constructor(context: Context, themeResId: Int) : super(
        context,
        themeResId
    ) {
    }

    protected constructor(
        context: Context,
        cancelable: Boolean,
        cancelListener: DialogInterface.OnCancelListener?
    ) : super(context, cancelable, cancelListener) {
    }

    class Builder : AlertDialog.Builder {
        constructor(context: Context) : super(context) {}
        constructor(context: Context, themeResId: Int) : super(
            context,
            themeResId
        ) {
        }

        override fun show(): AlertDialog {
            val dialog = create()
            dialog.show()
            val commitBtn = dialog.getButton(DialogInterface.BUTTON_POSITIVE)
            commitBtn?.setTextColor(Color.BLUE)
            var cancelBtn = dialog.getButton(DialogInterface.BUTTON_NEGATIVE)
            cancelBtn?.setTextColor(Color.BLUE)
            cancelBtn = dialog.getButton(DialogInterface.BUTTON_NEUTRAL)
            cancelBtn?.setTextColor(Color.BLUE)
            return dialog
        }
    }

    override fun setOnShowListener(listener: DialogInterface.OnShowListener?) {
        super.setOnShowListener(listener)
    }
    override fun show() {
        super.show()
        val commitBtn = getButton(DialogInterface.BUTTON_POSITIVE)
        commitBtn?.setTextColor(Color.RED)
        var cancelBtn = getButton(DialogInterface.BUTTON_NEGATIVE)
        cancelBtn?.setTextColor(Color.RED)
        cancelBtn = getButton(DialogInterface.BUTTON_NEUTRAL)
        cancelBtn?.setTextColor(Color.RED)
    }

    override fun cancel() {
        
    }

}